package com.charlie.riven;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import cn.jpush.android.api.JPushInterface;
import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created
 * Author:Charlie Wei[]
 * Email:charlie_net@163.com
 * Date:2015/10/13
 */
public class NotificationActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.notification_activity);
        View con = findViewById(R.id.li_notification);
        // 推送通知的数据
        Bundle bundle = getIntent().getExtras();
        if (bundle != null) {
            // 获取bundle里面附加的的Json数据
            String string = bundle.getString(JPushInterface.EXTRA_EXTRA);
            if (string != null) {
                try {
                    JSONObject jsonObject = new JSONObject(string);
                    String type = jsonObject.getString("type");
                    if (type.equals("1")){
                        // 更改布局容器的背景
                        con.setBackgroundColor(Color.BLUE);
                    }else {
                        con.setBackgroundColor(Color.CYAN);
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}